import { http } from "@/pages/utils/Http";

export interface User {
  phone: string;
  password: string;
}

export interface RegisterResponse {
  code: number;
  message: string;
  data: User;
}

export interface ResetPasswordResponse {
  code: number;
  message: string;
}

export interface LoginResponse {
  code: number;
  message: string;
  data: {
    id: number;
    username: string;
    phone: string;
  };
}

export interface UserStats {
  like_count: number;
  follow_count: number;
  fan_count: number;
  work_issued: number;
  work_collect: number;
}

export interface UserInfo {
  id: number;
  username: string;
  avatar?: string;
  nickname: string;
  bio?: string;
  stats: UserStats;
}

export interface UserInfoResponse {
  code: number;
  message: string;
  data: UserInfo;
}

// ===== 作品相关 =====

export interface WorkAttribute {
  trait: string;
  value?: string;
  rarity?: string;
}

export interface WorkTransaction {
  type: string; // 发行 / 购买 / 转让 等
  user: string;
  price: string;
  date: string;
}

export interface WorkDetail {
  id: number;
  name: string;
  description: string;
  image: string; // base64 或 URL
  price: string;
  chain: string;
  work_id?: string; // uuid
  status?: string;
  token_id?: string;
  minted_time?: string;
  attributes: WorkAttribute[];
  transactions: WorkTransaction[];
  // 系列名称，例如 "DigiDaigaku #1600"
  series?: string;
  // 当前版号、总版号
  edition?: string | number;
  total_edition?: string | number;
  /** 当前剩余版号数量 */
  remaining_edition?: string | number;

  author: {
    id?: number;
    username?: string;
    avatar?: string;
    nickname: string;
    bio?: string;
  };
}

export interface WorkDetailResponse {
  code: number;
  message: string;
  data: WorkDetail;
}

// ===== 首页数据 =====
export interface Banner {
  id: number;
  img: string;
  title?: string;
  jump_link?: string;
}

export interface Category {
  id?: number;
  name: string;
  icon: string;
}

export interface WorkCard {
  id: number;
  name: string;
  img: string;
  desc?: string;
  price?: string;
  likeCount?: number;
  liked?: boolean;
  verified?: number | boolean;
  author?: string;
}

export interface HomeResponse {
  code: number;
  message: string;
  data: {
    banners: Banner[];
    categories: Category[];
    hotList: WorkCard[];
    recentSold: WorkCard[];
  };
}
